<?php
    $globalErrors = '';
    if( isset( $errorsModel ) && $errorsModel instanceof ErrorsModelVO )
    {
        $manager      = new ErrorsModelManager( $errorsModel );
        $globalErrors = HtmlHelper::renderGlobalErrors( $manager );
    }
    if( !isset($result) || !$result instanceof MediaVO ) $result = new MediaVO();
?>
<div id="title_bloc" class="app_contents">
    <h1>Gestion des Média de l'application <strong>: MEDIA</strong></h1>
</div>

<div id="description_bloc">
    Formulaire d'ajout d'un média.
</div>

<?php $this->config->includePartial( BackendModulesList::MAIN, 'flashes', array( 'flashes' => $flashes , 'globalErrors' => $globalErrors ) ) ;?>

<?php echo HtmlHelper::form( UriHelper::get( BackendModulesList::MEDIA, BackendActionsList::ADD ), array( 'id' => 'mediaAddForm' ), true ) ;?>

    <label for="label">Label</label><?php echo HtmlHelper::inputText( MediaModel::LABEL_FIELD, array( 'id' => 'media_label', 'value' => $result->label ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::LABEL_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::LABEL_FIELD )->message ); ?><br /><?php endif; ?>

    <label for="file">File</label><?php echo HtmlHelper::file( MediaModel::FILE_FIELD, array( 'id' => 'media_file' ) ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::FILE_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::FILE_FIELD )->message ); ?><br /><?php endif; ?>

    <label for="startAt">Start at</label><?php echo HtmlHelper::dateTime( MediaModel::START_AT_FIELD, $years, array(), false, $result->startAt ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::START_AT_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::START_AT_FIELD )->message ); ?><br /><?php endif; ?>

    <label for="EndAt">End at</label><?php echo HtmlHelper::dateTime( MediaModel::END_AT_FIELD, $years, array(), false, $result->endAt ) ; ?><br />
    <?php if( isset( $manager ) && $manager->hasError( MediaModel::END_AT_FIELD ) ): ?><?php echo HtmlHelper::errorForm( $manager->getError( MediaModel::END_AT_FIELD )->message ); ?><br /><?php endif; ?>

    <span class="submit"><?php echo HtmlHelper::submit( array( 'name' => 'submit', 'value' => 'Ajouter un média' ) ) ; ?></span>
</form>